home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Snippets / GetFileIcon 1.1 / Old Headers / GetFileIcon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-09  |  8.2 KB  |  341 lines  |  [TEXT/KAHL]

  1. #include <exceptions.h>
  2. #include <Finder.h>
  3. #include <Folders.h>
  4. #include <Types.h>
  5. #include <Icons.h>
  6. #include <Resources.h>
  7.  
  8.  
  9.  
  10.  
  11.  
  12. /*    Custom icons numbered -16496 appear in aliases to volumes and
  13.     servers.  I don't know where this is documented.    */
  14. #define    kVolumeAliasIconResource    -16496
  15.  
  16. typedef struct 
  17. {
  18.     OSType        fileCreator;
  19.     OSType        fileType;
  20.     short        DTRefNum;
  21. } GetIconData;
  22.  
  23.  
  24. /*  alignment type values  */
  25. typedef short    IconAlignmentType;
  26. #ifdef THINK_C
  27. enum {
  28.     atNone                = 0x0,
  29.     atVerticalCenter    = 0x1,
  30.     atTop                = 0x2,
  31.     atBottom            = 0x3,
  32.     atHorizontalCenter    = 0x4,
  33.     atAbsoluteCenter    = (atVerticalCenter | atHorizontalCenter),
  34.     atCenterTop            = (atTop | atHorizontalCenter),
  35.     atCenterBottom        = (atBottom | atHorizontalCenter),
  36.     atLeft                = 0x8,
  37.     atCenterLeft        = (atVerticalCenter | atLeft),
  38.     atTopLeft            = (atTop | atLeft),
  39.     atBottomLeft        = (atBottom | atLeft),
  40.     atRight                = 0xC,
  41.     atCenterRight        = (atVerticalCenter | atRight),
  42.     atTopRight            = (atTop | atRight),
  43.     atBottomRight        = (atBottom | atRight)
  44. };
  45.  
  46. /*  transform type values  */
  47. typedef short    IconTransformType;
  48.  
  49. enum {
  50.     ttNone                = 0x0,
  51.     ttDisabled            = 0x1,
  52.     ttOffline            = 0x2,
  53.     ttOpen                = 0x3,
  54.     ttLabel1            = 0x0100,
  55.     ttLabel2            = 0x0200,
  56.     ttLabel3            = 0x0300,
  57.     ttLabel4            = 0x0400,
  58.     ttLabel5            = 0x0500,
  59.     ttLabel6            = 0x0600,
  60.     ttLabel7            = 0x0700,
  61.     ttSelected            = 0x4000,
  62.     ttSelectedDisabled    = (ttSelected | ttDisabled),
  63.     ttSelectedOffline    = (ttSelected | ttOffline),
  64.     ttSelectedOpen        = (ttSelected | ttOpen)
  65. };
  66.  
  67. /*  Selector mask values  */
  68. typedef unsigned long    IconSelectorValue;    
  69.  
  70. enum {
  71.     svLarge1Bit            = 0x00000001,
  72.     svLarge4Bit            = 0x00000002,
  73.     svLarge8Bit            = 0x00000004,
  74.     svSmall1Bit            = 0x00000100,
  75.     svSmall4Bit            = 0x00000200,
  76.     svSmall8Bit            = 0x00000400,
  77.     svMini1Bit            = 0x00010000,
  78.     svMini4Bit            = 0x00020000,
  79.     svMini8Bit            = 0x00040000,
  80.     svAllLargeData        = 0x000000ff,
  81.     svAllSmallData        = 0x0000ff00,
  82.     svAllMiniData        = 0x00ff0000,
  83.     svAll1BitData        = (svLarge1Bit | svSmall1Bit | svMini1Bit),
  84.     svAll4BitData        = (svLarge4Bit | svSmall4Bit | svMini4Bit),
  85.     svAll8BitData        = (svLarge8Bit | svSmall8Bit | svMini8Bit),
  86.     svAllAvailableData    = 0xffffffff
  87. };
  88.  
  89.  
  90. typedef pascal OSErr (*IconAction)(ResType theType, Handle *theIcon, void *yourDataPtr);
  91. typedef pascal Handle (*IconGetter)(ResType theType, void *yourDataPtr);
  92.  
  93. #ifdef __cplusplus
  94. extern "C" {
  95. #endif
  96.  
  97.  
  98.  
  99.  
  100. pascal OSErr PlotIconID(const Rect *theRect,
  101.                             IconAlignmentType align,
  102.                             IconTransformType transform,
  103.                             short theResID)
  104.     = {0x303C, 0x0500, 0xABC9};
  105.     
  106. pascal OSErr NewIconSuite(Handle *theIconSuite)
  107.     = {0x303C, 0x0207, 0xABC9};
  108.     
  109. pascal OSErr AddIconToSuite(Handle theIconData,
  110.                             Handle theSuite,
  111.                             ResType theType)
  112.     = {0x303C, 0x0608, 0xABC9};
  113.     
  114. pascal OSErr GetIconFromSuite(Handle *theIconData,
  115.                             Handle theSuite,
  116.                             ResType theType)
  117.     = {0x303C, 0x0609, 0xABC9};
  118.     
  119. pascal OSErr ForEachIconDo(Handle theSuite,
  120.                             IconSelectorValue selector,
  121.                             IconAction action,
  122.                             void *yourDataPtr)
  123.     = {0x303C, 0x080A, 0xABC9};
  124.     
  125. pascal OSErr GetIconSuite(Handle *theIconSuite,
  126.                             short theResID,
  127.                             IconSelectorValue selector)
  128.     = {0x303C, 0x0501, 0xABC9};
  129.     
  130. pascal OSErr DisposeIconSuite(Handle theIconSuite,
  131.                             Boolean disposeData)
  132.     = {0x303C, 0x0302, 0xABC9};
  133.     
  134. pascal OSErr PlotIconSuite(const Rect *theRect,
  135.                             IconAlignmentType align,
  136.                             IconTransformType transform,
  137.                             Handle theIconSuite)
  138.     = {0x303C, 0x0603, 0xABC9};
  139.     
  140. pascal OSErr MakeIconCache(Handle *theHandle,
  141.                             IconGetter makeIcon,
  142.                             void *yourDataPtr)
  143.     = {0x303C, 0x0604, 0xABC9};
  144.     
  145. pascal OSErr LoadIconCache(const Rect *theRect,
  146.                             IconAlignmentType align,
  147.                             IconTransformType transform,
  148.                             Handle theIconCache)
  149.     = {0x303C, 0x0606, 0xABC9};
  150.  
  151. pascal OSErr PlotIconMethod(const Rect *theRect,
  152.                             IconAlignmentType align,
  153.                             IconTransformType transform,
  154.                             IconGetter theMethod,
  155.                             void *yourDataPtr)
  156.     = {0x303C, 0x0805, 0xABC9};
  157.     
  158. pascal OSErr GetLabel(short labelNumber,
  159.                             RGBColor *labelColor,
  160.                             Str255 labelString)
  161.     = {0x303c, 0x050B, 0xABC9};
  162.     
  163. pascal Boolean PtInIconID(Point testPt,
  164.                             Rect *iconRect,
  165.                             IconAlignmentType alignment,
  166.                             short iconID)
  167.     = {0x303c, 0x060D, 0xABC9};
  168.     
  169. pascal Boolean PtInIconSuite(Point testPt,
  170.                             Rect *iconRect,
  171.                             IconAlignmentType alignment,
  172.                             Handle theIconSuite)
  173.     = {0x303c, 0x070E, 0xABC9};
  174.     
  175. pascal Boolean PtInIconMethod(Point testPt,
  176.                             Rect *iconRect,
  177.                             IconAlignmentType alignment,
  178.                             IconGetter theMethod,
  179.                             void *yourDataPtr)
  180.     = {0x303c, 0x090F, 0xABC9};
  181.     
  182. pascal Boolean RectInIconID(Rect *testRect,
  183.                             Rect *iconRect,
  184.                             IconAlignmentType alignment,
  185.                             short iconID)
  186.     = {0x303c, 0x0610, 0xABC9};
  187.     
  188. pascal Boolean RectInIconSuite(Rect *testRect,
  189.                             Rect *iconRect,
  190.                             IconAlignmentType alignment,
  191.                             Handle theIconSuite)
  192.     = {0x303c, 0x0711, 0xABC9};
  193.     
  194. pascal Boolean RectInIconMethod(Rect *testRect,
  195.                             Rect *iconRect,
  196.                             IconAlignmentType alignment,
  197.                             IconGetter theMethod,
  198.                             void *yourDataPtr)
  199.     = {0x303c, 0x0912, 0xABC9};
  200.     
  201. pascal OSErr IconIDToRgn(RgnHandle theRgn,
  202.                             Rect *iconRect,
  203.                             IconAlignmentType alignment,
  204.                             short iconID)
  205.     = {0x303c, 0x0613, 0xABC9};
  206.     
  207. pascal OSErr IconSuiteToRgn(RgnHandle theRgn,
  208.                             Rect *iconRect,
  209.                             IconAlignmentType alignment,
  210.                             Handle theIconSuite)
  211.     = {0x303c, 0x0714, 0xABC9};
  212.     
  213. pascal OSErr IconMethodToRgn(RgnHandle theRgn,
  214.                             Rect *iconRect,
  215.                             IconAlignmentType alignment,
  216.                             IconGetter theMethod,
  217.                             void *yourDataPtr)
  218.     = {0x303c, 0x0915, 0xABC9};
  219.     
  220. pascal OSErr SetSuiteLabel(Handle theSuite, short theLabel)
  221.     = {0x303C, 0x0316, 0xABC9};
  222.  
  223. pascal short GetSuiteLabel(Handle theSuite)
  224.     = {0x303C, 0x0217, 0xABC9};
  225.  
  226. pascal OSErr GetIconCacheData(Handle theCache, void **theData)
  227.     = {0x303C, 0x0419, 0xABC9};
  228.         
  229. pascal OSErr SetIconCacheData(Handle theCache, void *theData)
  230.     = {0x303C, 0x041A, 0xABC9};
  231.         
  232. pascal OSErr GetIconCacheProc(Handle theCache, IconGetter *theProc)
  233.     = {0x303C, 0x041B, 0xABC9};
  234.         
  235. pascal OSErr SetIconCacheProc(Handle theCache, IconGetter theProc)
  236.     = {0x303C, 0x041C, 0xABC9};
  237.     
  238. pascal OSErr PlotIconHandle(const Rect *theRect,
  239.                             IconAlignmentType align,
  240.                             IconTransformType transform,
  241.                             Handle theIcon)
  242.     = {0x303C, 0x061D, 0xABC9};
  243.     
  244. pascal OSErr PlotSICNHandle(const Rect *theRect,
  245.                             IconAlignmentType align,
  246.                             IconTransformType transform,
  247.                             Handle theSICN)
  248.     = {0x303C, 0x061E, 0xABC9};
  249.     
  250. pascal OSErr PlotCIconHandle(const Rect *theRect,
  251.                             IconAlignmentType align,
  252.                             IconTransformType transform,
  253.                             CIconHandle theCIcon)
  254.     = {0x303C, 0x061F, 0xABC9};
  255.     
  256. #ifdef __cplusplus
  257. }
  258. #endif
  259.  
  260.  
  261. #endif    // THINK_C
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. pascal OSErr GetFileIcon(
  269. /* --> */    FSSpec                *thing,
  270. /* --> */    IconSelectorValue    iconSelector,
  271. /* <-- */    Handle                *theSuite);
  272.  
  273. Boolean    IsVolEjected( short vRefNum );
  274.  
  275. OSErr    GetCustomFileIcon(
  276. /* --> */    FSSpec                *filespec,
  277. /* --> */    IconSelectorValue    iconSelector,
  278. /* <-- */    Handle                *theSuite);
  279.  
  280. OSErr    GetNormalFileIcon(
  281. /* --> */    CInfoPBRec            *cpb,
  282. /* --> */    IconSelectorValue    iconSelector,
  283. /* <-- */    Handle                *theSuite);
  284.  
  285. void GetFinderFilename(
  286. /* <-- */    StringPtr       _finderFilename);
  287.  
  288. //static    pascal OSErr GetIconProc(ResType theType, Handle *theIcon, void *yourDataPtr);
  289. pascal OSErr GetIconProc(ResType theType, Handle *theIcon, void *yourDataPtr);
  290.  
  291. //static    short    FindDesktopDatabase(
  292. short    FindDesktopDatabase(
  293. /* --> */    short    firstVRefNum,
  294. /* --> */    OSType    fileCreator);
  295.  
  296. //static    Boolean    InOneDesktop(
  297. Boolean    InOneDesktop(
  298. /* --> */    short    vRefNum,
  299. /* --> */    OSType    fileCreator,
  300. /* <-- */    short    *dtRefNum);
  301.  
  302. pascal OSErr GetResourceIcons(
  303. /* <-- */    Handle    *theSuite,
  304. /* --> */    short    theID,
  305. /* --> */    long    theSelector);
  306.  
  307. //static pascal OSErr CopyOneIcon(
  308. pascal OSErr CopyOneIcon(
  309. /* --> */    ResType        theType,
  310. /* <-> */    Handle        *theIcon,
  311. /* --- */    void        *yourDataPtr);
  312.  
  313. OSErr CopyEachIcon(
  314. /* <-> */    Handle theSuite);
  315.  
  316. short    FindGenericIconID(
  317. /* --> */    OSType theType,
  318. /* <-- */    Boolean    *inFinder);
  319.  
  320. pascal OSErr Get1IconSuite(
  321. /* <-- */    Handle    *theSuite,
  322. /* --> */    short    theID,
  323. /* --> */    long    theSelector);
  324.  
  325. //static pascal OSErr Get1Icon(
  326. pascal OSErr Get1Icon(
  327. /* --> */    ResType    theType,
  328. /* <-> */    Handle    *theIcon,
  329. /* --> */    short    *resID);
  330.  
  331. pascal OSErr TestHandle(ResType theType, Handle *theIcon, void *yourDataPtr);
  332.  
  333. Boolean IsSuiteEmpty( Handle theSuite );
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.